<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Advanced Constructs</title>
		<link type="text/css" rel="stylesheet" href="PLUGINS_ROOT/org.polarsys.capella.doc/html/styles.css"/>
	</head>
	<body>
		<h1 id="Advanced_Constructs">Advanced Constructs</h1>
		<p>These constructs enable the modeler to go further, but are less important for beginners. They require more time and practice to be mastered.</p>
		<h2 id="Class_and_Type_advanced_features">Class and Type advanced features</h2>
		<p>Note that most of these advanced features are also available for Properties, Associations, Echange Item Elements, etc.</p>
		<h3 id="isDiscrete">isDiscrete</h3>
		<p>When the type is declared discrete, it means that it defines non continuous or separable values. Examples of common discrete types are Boolean and Enumeration. This quality is required for a type used as a discriminant in a [ union] class.</p>
		<p><center>
			<img border="0" src="Images/image119.png"/></center>
		</p>
		<h3 id="isDerived">isDerived</h3>
		<p>Specifies whether the property or association is derived from other model elements such as other properties, associations or constraints. The default value is false.</p>
		<p>For instance, a common derived property is the age of a Person, derived from the birthDate. The notation of a derived property is “/ derivedProperty”. </p>
		<p><center>
			<img border="0" src="Images/image120.png"/></center>
		</p>
		<p>A good practice is to explain how the property is derived within the description field of the property or its summary. </p>
		<p><center>
			<img border="0" src="Images/image121.jpg"/></center>
		</p>
		<p>Association roles can also be derived as in the following example. A person may own several cars. As each car contains 4 wheels, the person also owns all the wheels!</p>
		<p><center>
			<img border="0" src="Images/image122.png"/></center>
		</p>
		<p><center>
			<img border="0" src="Images/image123.jpg"/></center>
		</p>
		<h3 id="isOrdered">isOrdered</h3>
		<p>For multivalued elements (Max. Card &gt; 1), this feature specifies whether the values in an instantiation of this element are sequentially ordered (Default is false).</p>
		<p>For instance, when you play chess, a game consists in a sequence of moves:</p>
		<p><center>
			<img border="0" src="Images/image124.png"/></center>
		</p>
		<p><center>
			<img border="0" src="Images/image125.jpg"/></center>
		</p>
		<p>If the element is specified as ordered (i.e., isOrdered is true), then the set of values in an instantiation of this element is ordered. This ordering implies that there is a mapping from positive or null integers to the elements of the set of values. If an element is not multivalued, then the value for isOrdered has no semantic effect.</p>
		<p>If the element is specified as unordered (i.e., isOrdered is false), then no assumptions can be made about the order of the values in an instantiation of this element. </p>
		<p><center>
			<img border="0" src="Images/image126.png"/></center>
		</p>
		<p>When one or more ends of the association are ordered, instances of association (links) carry ordering information in addition to their end values.</p>
		<h3 id="isUnique">isUnique</h3>
		<p>For multivalued elements (Max. Card &gt; 1), this feature specifies whether the values in an instantiation of this element are unique (Default is 
			<i>false</i> in Capella, although it should be 
			<i>true</i>).
		</p>
		<p>When isUnique is true, the collection of values may not contain duplicates. This is the most common case, as in the next figure (A person may own several cars, which are all different!).</p>
		<p><center>
			<img border="0" src="Images/image127.png"/></center>
		</p>
		<p>When one or more ends of the association have isUnique=false, it is possible to have several links associating the same set of instances. In such a case, links carry an additional identifier apart from their end values. For instance if one wants to record a log of user connections, and count the number of times a specific user logged in during a specific duration, isUnique should be false. In this case, an additional attribute (such as connection time) may be needed.</p>
		<p>Another simple example is shown on the next figure. In the game of chess, a game is a sequence of moves, involving one chess piece going from one square to another one. Several different moves may involve exactly the same piece and the same squares.</p>
		<p><center>
			<img border="0" src="Images/image128.png"/></center>
		</p>
		<p>In combination with the feature [ isOrdered], the following table (from UML 2.4 specification) indicates pertinent collection types:</p>
		<p><center>
			<img border="0" src="Images/image129.jpg"/></center>
		</p>
		<p>We can add that these two features are particularly important for code generation, but much less for pure system engineering modeling.</p>
		<h3 id="Is_Final">Is Final</h3>
		<p>If a type is marked as isFinal, then it cannot be any longer specialized by any sub-type.</p>
		<p>Take care: if a type is marked as isFinal, and you still create a sub-type, there is no error or even warning produced by the model-checking tool.</p>
		<h3 id="Is_Read_Only">Is Read Only</h3>
		<p>If a property is marked as readOnly, then it cannot be updated once it has been assigned an initial value (Default is 
			<i>false</i>).
		</p>
		<p>For instance, the birthdate of a Person is normally readOnly, unlike the age or weight.</p>
		<p><center>
			<img border="0" src="Images/image130.jpg"/></center>
		</p>
		<h3 id="Pattern">Pattern</h3>
		<p>Numeric, String and Enumeration types can be defined with a pattern which specifies the lexical space for their literal values. The syntax for expressing pattern is that of regular expressions in Java.</p>
		<p>By default (when the pattern field is left empty in the type editor) a numeric type with kind:</p>
		<ul>
			<li>
				<ul>
					<li>INTEGER has a built-in pattern which is (+|-)?([1-9][0-9]*|0)</li>
					<li>FLOAT has a built-in pattern which is (+|-)?([0-9]*[.][0-9]+|[0-9]+[.][0-9]*)(e|E)(+|-)[0-9]+</li>
				</ul>
			</li>
		</ul>
		<p>When running the validation tool, if any literal does not conform to the pattern defined for its type an error is raised.</p>
		<h3 id="Visibility">Visibility</h3>
		<p>This feature comes from UML and object-oriented languages.</p>
		<p>VisibilityKind is an enumeration type that defines literals to determine the visibility of elements in a model:</p>
		<ul>
			<li>A public element is visible to all elements that can access the contents of the namespace that owns it.</li>
			<li>A private element is only visible inside the namespace that owns it.</li>
			<li>A protected element is visible to elements that have a generalization relationship to the namespace that owns it.</li>
			<li>A package element is owned by a namespace that is not a package, and is visible to elements that are in the same package as its owning namespace.</li>
		</ul>
		<h3 id="Super">Super</h3>
		<p>This field indicates the super-types (or generalized types) of the current type. It is empty by default.</p>
		<p><center>
			<img border="0" src="Images/image131.jpg"/></center>
		</p>
		<p>As soon as a Generalization relationship is established, the “Super” field is automatically filled, as we saw in § [ Generalization]. Take care that this field can be edited. For instance, if you remove the 
			<i>Vehicle</i> super-class from the 
			<i>Car</i> Properties sheet, it deletes the generalization relationship and modifies the underlying model!
		</p>
		<p><center>
			<img border="0" src="Images/image132.jpg"/></center>
		</p>
		<p><center>
			<img border="0" src="Images/image133.png"/></center>
		</p>
		<p>It is possible to allow multiple inheritance to define several super types.</p>
		<p><center>
			<img border="0" src="Images/image134.jpg"/></center>
		</p>
		<p>Be careful: this action is not recommended. That is why it is not the default option, for it has different meanings depending on the targeted technology (e.g. with respect to late binding and overloading), it is not systematically supported, and it makes automatic processing of models a lot more complex.</p>
		<h2 id="Expression">Expression</h2>
		<p>An Expression is a formula that yields values when evaluated in a context.</p>
		<h3 id="Unary_Expression">Unary Expression</h3>
		<p>A Unary Expression is one specific kind of Expression consisting of one Operator (+, -, not, or, etc.) and exactly one Operand. The Operand can itself be an Expression.</p>
		<p>We can for instance create a Factorial Unary Expression to calculate the factorial of any interesting value.</p>
		<p><center>
			<img border="0" src="Images/image135.png"/></center>
		</p>
		<p><center>
			<img border="0" src="Images/image136.jpg"/></center>
		</p>
		<h3 id="Binary_expression">Binary expression</h3>
		<p>A Binary Expression is one specific kind of Expression consisting of one Operator (+, -, not, or, etc.) and exactly two Operands. Operands can themselves be Expressions.</p>
		<p><center>
			<img border="0" src="Images/image137.png"/></center>
		</p>
		<p>Let us give a simple example with an expression calculating the total number of satellites in the constellation&nbsp;: </p>
		<p><center>
			<img border="0" src="Images/image138.png"/></center>
		</p>
		<p>It is then possible to create a [ Reference] from the Expression, and to use this reference for association cardinalities:</p>
		<p><center>
			<img border="0" src="Images/image139.png"/></center>
		</p>
		<h2 id="Collection">Collection</h2>
		<p>A Collection is a data modeling construct allowing the definition of sets of elements. </p>
		<p><center>
			<img border="0" src="Images/image140.png"/></center>
		</p>
		<p>To properly define a Collection, you have to choose the type of its elements. It can be a class, a complex type or a simple type. Min and max cardinalities should be indicated and they appear in diagrams. </p>
		<p><center>
			<img border="0" src="Images/image141.jpg"/></center>
		</p>
		<p>Collections can be indexed. The type of an index should be discrete. Very often, collections are not indexed. The implicit index is then an Integer. If the collection has one or several indexes, the cardinalities should be consistent with the product of the index cardinalities.</p>
		<p>For example, a chess board consists in exactly 64 squares, indexed by the couple (column, row).</p>
		<p><center>
			<img border="0" src="Images/image142.png"/></center>
		</p>
		<p><center>
			<img border="0" src="Images/image143.jpg"/></center>
		</p>
		<p>Collections can be Sequences or Arrays (note that Capella  does not offer yet set or bags, for instance). This distinction is closely related to the Interface Definition Language (IDL) constructs from OMG:</p>
		<ul>
			<li>Sequences in IDL may be either unbounded (no maximum size) or bounded (a specific maximum size). </li>
			<li>IDL arrays are always of a fixed size. </li>
			<li>An IDL sequence is similar to a one-dimensional array of elements, but it can be unbounded.</li>
		</ul>
		<p>Note that Collections are more design concepts than analysis concepts. To model domain concepts collections, it is often sufficient to use the cardinality adornment on an association, possibly with the “ordered” keyword.</p>
		<p>Cardinalities of Exchange Item Elements can also stbe used to prevent creating unnecessary Collections in the Data Model.</p>
		<p><center>
			<img border="0" src="Images/image144.jpg"/></center>
		</p>
		<p>In the example above, the Exchange Item Element dci with a [0..24] cardinality prevents from creating an unnecessary Collection of Images (
			<i>CollectedImages</i>) in the Data Model.
		</p>
		<h2 id="Union_.2F_Variant">Union / Variant</h2>
		<p>Unions and Variants are advanced structures that can take different forms according to the values of a Discriminant. </p>
		<p>The first thing we have to define on the Union is which 
			<i>UnionProperty</i> will be the discriminant. We have to create an [ Enumeration], and type one 
			<i>UnionProperty</i> by this Enumeration, and specify on the Union that we want to use it as a discriminant.
		</p>
		<p><center>
			<img border="0" src="Images/image145.png"/></center>
		</p>
		<p><center>
			<img border="0" src="Images/image146.jpg"/></center>
		</p>
		<p>Let us give a simple example: according to a Security Policy, either normal or protected, employees will just need a name or an additional password to ask for a printing job.</p>
		<p>We just have to specify two new 
			<i>UnionProperties</i>, of types 
			<i>Login</i> or 
			<i>ProtectedLogin</i>, and we can for each of them define the pertinent Qualifier.
		</p>
		<p><center>
			<img border="0" src="Images/image147.png"/></center>
		</p>
		<p>These constructs are mainly used in relation with software programming languages. For instance, in the Interface Definition Language (IDL) from OMG, a union is essentially a group of attributes, only one of which can be active at a time, according to the discriminant. A union saves memory space, because the amount of storage required for a union is the amount necessary to store its largest attribute. And Ada discriminated records are very similar to Capella  variants.</p>
		<p>Differences between Union and Variant are the following:</p>
		<ul>
			<li>In the Union, one value of the discriminant must be associated to at most one property and a property must always be associated to a value of the discriminant;</li>
			<li>In the Variant, one value of the discriminant can be associated to any number (0 or more) of properties. By convention a variant property that has no discriminant value associated is deemed to be associated to all values of the discriminant: it is the fixed part.</li>
		</ul>
		<p>Differences between OMG/IDL and Capella /Union are the following:</p>
		<ul>
			<li>Major: Capella /Union has no default clause; </li>
			<li>Minor: in Capella , the discriminant of a Union is a specific property of the Union.</li>
		</ul>
		<p>Differences between ADA/discriminated record and Capella /Variant are the following:</p>
		<ul>
			<li>Major: Capella / Variant has no default clause; </li>
			<li>Major: in Capella , a Variant only supports one discriminant.</li>
		</ul>
		<h2 id="Values_and_References">Values and References</h2>
		<p>Values are instances of classes and data types and allow defining fixed data values. There are named values and anonymous values. Only named values can be reused to specify other model elements, such as [ cardinalities], [ default value], [ null value], [ min/max], [ length].</p>
		<h3 id="Simple_Values">Simple Values</h3>
		<p>Simple values were explained in the Basic Constructs chapter:</p>
		<ul>
			<li>See [ Literal Numeric Value]</li>
			<li>See [ Enumeration Literal]</li>
			<li>See [ Literal Boolean Value]</li>
			<li>See [ Literal String Value]</li>
			<li>…</li>
		</ul>
		<h3 id="Complex_Values">Complex Values</h3>
		<p>Complex Value is the valuation of a structured element (for example, [ Class] or [ Union]). It contains one Value Part per Property owned by the structured element typing the Complex Value.</p>
		<p>A Value Part is thus a valuation of one specific Property of the structured element. The type of the Value Part is the same as the type of the Property.</p>
		<h3 id="Collection_Values">Collection Values</h3>
		<p>Collection Value is the valuation of a [ Collection]. It corresponds to a succession of Values for the type of the Collection.</p>
		<h3 id="References">References</h3>
		<p>Unlike Literals, References (Numeric, String, Expression, Enumeration, Boolean, Complex Value) allow defining Data Values related to other Data Values.</p>
		<p>A Reference Data Value can target another Reference Data Value, A Literal Data Value or a Class Property.</p>
		<p><center>
			<img border="0" src="Images/image148.png"/></center>
		</p>
		<p><center>
			<img border="0" src="Images/image149.jpg"/></center>
		</p>
		<h2 id="Modeling_Accelerators">Modeling Accelerators</h2>
		<h3 id="Exchange_Items_Propagation_to_Function_Ports">Exchange Items Propagation to Function Ports</h3>
		<p>Effect: If an Exchange Item is conveyed by a Functional Exchange linking two Function Ports, this accelerator will also associate it to each Function Port.</p>
		<p>This is interesting mainly when you want to get an autonomous specification of inputs/ outputs for each Function, via its owned ports.</p>
		<p><center>
			<img border="0" src="Images/image150.jpg"/></center>
		</p>
		<p><center>
			<img border="0" src="Images/image151.jpg"/></center>
		</p>
		<h3 id="Interface_Generation_from_Allocated_Functions">Interface Generation from Allocated Functions</h3>
		<p>Effect: Analyze the Component Exchanges, the Functional Exchanges they carry and the Exchange Items associated to the Functional Exchanges to generate a set of [ Interfaces] between Components.</p>
		<p>Example: Two components, three Component Exchanges, four Functional Exchanges associated to Exchange Items.</p>
		<p><center>
			<img border="0" src="Images/image152.png"/></center>
		</p>
		<p>Result of the generation of Interfaces: One Interface is created per Component Exchange. All Exchange Items coming from different Functional Exchanges are aggregated in the same Interface.</p>
		<p><center>
			<img border="0" src="Images/image153.png"/></center>
		</p>
	</body>
</html>